package com.tron.sync.syncwfinfoindex;

import lombok.Data;
import org.springframework.util.StringUtils;

@Data
public class SearchExecuteEntity {
    /**
     * 1 是否审查环节
     */
    private boolean approveNode = false;
    /**
     * 2 任务id
     */
    private String taskId="";
    /**
     * 3 环节id
     */
    private String nodeId="";

    /**
     * 4 环节名称
     */
    private String nodeName="";

    /**
     * 5 办理人id
     */
    private String assignUserId="";

    /**
     * 6 办理人
     */
    private String assignUser="";


    /**
     * 7 办理人部门id
     */
    private String depId="";

    /**
     * 8 办理人部门
     */
    private String dep="";

    /**
     * 9 办理人机构id
     */
    private String orgId="";

    /**
     * 10 办理人机构
     */
    private String org="";

    /**
     * 11 发送人id
     */
    private String sendUserId="";

    /**
     * 12 发送人
     */
    private String sendUser="";

    /**
     * 13 发送人部门id
     */
    private String sendDepId="";

    /**
     * 14 发送人部门
     */
    private String sendDep="";


    /**
     * 15 发送人机构id
     */
    private String sendOrgId="";

    /**
     * 16 发送人机构
     */
    private String sendOrg="";
    private String sendTime="";

    public String getSendTime() {
        return sendTime;
    }

    public void setSendTime(String sendTime) {
        this.sendTime = sendTime;
    }

    public SearchExecuteEntity copy() {
        SearchExecuteEntity cp = new SearchExecuteEntity();
        cp.setApproveNode(this.isApproveNode());
        cp.setTaskId(this.getTaskId());
        cp.setNodeId(this.getNodeId());
        cp.setNodeName(this.getNodeName());
        cp.setAssignUserId(this.getAssignUserId());
        cp.setAssignUser(this.getAssignUser());
        cp.setDepId(this.getDepId());
        cp.setDep(this.getDep());
        cp.setOrgId(this.getOrgId());
        cp.setOrg(this.getOrg());
        cp.setSendUserId(this.getSendUserId());
        cp.setSendUser(this.getSendUser());
        cp.setSendDepId(this.getSendDepId());
        cp.setSendDep(this.getSendDep());
        cp.setSendOrgId(this.getSendOrgId());
        cp.setSendOrg(this.getSendOrg());
        cp.setSendTime(this.getSendTime());
        return cp;
    }

    @Override
    public String toString() {
        return "approveNode<" + approveNode +
                ">taskId<" + taskId +
                ">nodeId<" + nodeId +
                ">nodeName<" + nodeName +
                ">assignUserId<" + assignUserId +
                ">assignUser<" + assignUser +
                ">depId<" + depId +
                ">dep<" + dep +
                ">orgId<" + orgId +
                ">org<" + org +
                ">sendUserId<" + sendUserId +
                ">sendUser<" + sendUser +
                ">sendDepId<" + sendDepId +
                ">sendDep<" + sendDep +
                ">sendOrgId<" + sendOrgId +
                ">sendTime<" + sendTime +
                ">sendOrg<" + sendOrg +
                ">";
    }
    public static SearchExecuteEntity parseToObject(String str) {
        SearchExecuteEntity see = new SearchExecuteEntity();
        if(StringUtils.isEmpty(str)) return see;
        see.setApproveNode(getParam(str,"approveNode").indexOf("true")>=0);
        see.setTaskId(getParam(str,"taskId"));
        see.setNodeId(getParam(str,"nodeId"));
        see.setNodeName(getParam(str,"nodeName"));
        see.setAssignUserId(getParam(str,"assignUserId"));
        see.setAssignUser(getParam(str,"assignUser"));
        see.setDepId(getParam(str,"depId"));
        see.setDep(getParam(str,"dep"));
        see.setOrgId(getParam(str,"orgId"));
        see.setOrg(getParam(str,"org"));
        see.setSendUserId(getParam(str,"sendUserId"));
        see.setSendUser(getParam(str,"sendUser"));
        see.setSendDepId(getParam(str,"sendDepId"));
        see.setSendDep(getParam(str,"sendDep"));
        see.setSendOrgId(getParam(str,"sendOrgId"));
        see.setSendOrg(getParam(str,"sendOrg"));
        see.setSendTime(getParam(str,"sendTime"));
        return see;
    }
    private static String getParam(String str,String key){
    	key = key + "<";
        if(str.indexOf(key)<0){
            return "";
        }
        String[] split = str.split(key);
        String substring = split[1].substring(0, split[1].indexOf('>'));
        return substring;
    }
}
